Security and Authentication

Store Extra Information at Sign-In Time

Description
This example demonstrates store extra information at sign-in time.
Variables
Table Name
Select the table where user information is stored
UserId Field
Select the UserId field
Applies to
SignIn class
Code
 
''' 
''' Store information in session variable in loginSucceeded event.
''' This event is raised after user has successfully logged-in
''' Instead of creating a where string from database you might choose other
''' information to store (like time of sign in, for example).
''' 
Protected Sub SignIn_LoginSucceeded(ByVal sender as Object, ByVal e as System.EventArgs) Handles Me.LoginSucceeded
        
        ' [BEGIN]: adding more info to session
        Dim userId As String = BaseClasses.Utils.SecurityControls.GetCurrentUserID()
        
        ' Create where string 
        Dim whereStr as String = ${${Table Name}ClassName}.${UserId Field}.UniqueName & " = " & "'" & userId & "'"
     
        ' Create the order by string.
        Dim orderBy As BaseClasses.Data.OrderBy  = Nothing
        Dim myRecord As ${${Table Name}RecordClassName} = ${${Table Name}ClassName}.GetRecord(whereStr, orderBy)
       
       ' Set the extra information in the Session variable as shown below. 
       ' Replace FirstName and LastName by you field names
       ' where FirstName and LastName are the names of the cloumns that contiain the first name and the last name
       ' Dim firstName As String = myRecord.FirstName
       ' Dim lastName As String = myRecord.LastName
       ' System.Web.HttpContext.Current.Session("firstName") = firstName
       ' System.Web.HttpContext.Current.Session("lastName") = lastName
       ' [END]: adding more info to session       
End Sub
     

Terms of Service Privacy Statement